package com.example.testandroid.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.ToggleButton;

import com.example.testandroid.R;

public class ToggleButtonTestActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_toggle_button_test);
		ToggleButton toggle = (ToggleButton)findViewById(R.id.toggleButton);
		final LinearLayout test = (LinearLayout)findViewById(R.id.testToggle);
		toggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if(isChecked){
					test.setOrientation(1);//垂直布局
				}
				else{
					test.setOrientation(0);//水平布局
				}
				
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.toggle_button_test, menu);
		return true;
	}

}
